home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / toolbox.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  57.7 KB  |  1,752 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  22 Aug 2000
  22. //  Author:         bwk
  23. //
  24. //  Description:
  25. //        This script creates the Toolbox.
  26. //
  27.  
  28. proc createConfigurationPopupMenu(string $parent)
  29. //
  30. //    Description:
  31. //        Create a popup menu containing pane layout configurations.
  32. //
  33. //    Arguments:
  34. //        parent - The parent control for the popup menu.
  35. //
  36. {
  37.     //
  38.     //    Add popup menu containing names of panel configurations.
  39.     //
  40.     popupMenu -parent $parent -button 3; 
  41.  
  42.     menuItem -label "Single Pane"
  43.         -annotation (getRunTimeCommandAnnotation("SingleViewArrangement"))
  44.         -command ("SingleViewArrangement");
  45.  
  46.     menuItem -label "Two Panes Side by Side"
  47.         -annotation (getRunTimeCommandAnnotation("TwoSideBySideViewArrangement"))
  48.         -command ("TwoSideBySideViewArrangement");
  49.  
  50.     menuItem -label "Two Panes Stacked"
  51.         -annotation (getRunTimeCommandAnnotation("TwoStackedViewArrangement"))
  52.         -command ("TwoStackedViewArrangement");
  53.  
  54.     menuItem -label "Three Panes Split Top"
  55.         -annotation (getRunTimeCommandAnnotation("ThreeTopSplitViewArrangement"))
  56.         -command ("ThreeTopSplitViewArrangement");
  57.  
  58.     menuItem -label "Three Panes Split Left"
  59.         -annotation (getRunTimeCommandAnnotation("ThreeLeftSplitViewArrangement"))
  60.         -command ("ThreeLeftSplitViewArrangement");
  61.  
  62.     menuItem -label "Three Panes Split Bottom"
  63.         -annotation (getRunTimeCommandAnnotation("ThreeBottomSplitViewArrangement"))
  64.         -command ("ThreeBottomSplitViewArrangement");
  65.  
  66.     menuItem -label "Three Panes Split Right"
  67.         -annotation (getRunTimeCommandAnnotation("ThreeRightSplitViewArrangement"))
  68.         -command ("ThreeRightSplitViewArrangement");
  69.  
  70.     menuItem -label "Four Panes"
  71.         -annotation (getRunTimeCommandAnnotation("FourViewArrangement"))
  72.         -command ("FourViewArrangement");
  73.  
  74.     //    Add an item for saving the current layout.
  75.     //
  76.     menuItem -divider true;
  77.     
  78.     menuItem -label "Save Current Layout..." -command ("toolboxSaveCurrentLayout");
  79. }
  80.  
  81. proc string getQuickButtonImage(string $label)
  82. //
  83. //    Description:
  84. //        Return the image associated with the specified configuration label.
  85. //
  86. //    Arguments:
  87. //        $label - The panel configuration label.
  88. //
  89. //    Returns:
  90. //        The image associated with the panel configuration. May return an empty
  91. //        string.
  92. //
  93. {
  94.     string $result = "", $panelConfiguration;
  95.  
  96.     $panelConfiguration = `getPanel -configWithLabel $label`;
  97.  
  98.     if ("" != $panelConfiguration) {
  99.         $result = `panelConfiguration -query -image $panelConfiguration`;
  100.         if ("" == $result) {
  101.             $result = `panelConfiguration -query -defaultImage $panelConfiguration`;
  102.         }
  103.     }
  104.  
  105.     return $result;
  106. }
  107.  
  108. proc setQuickButtonImage(string $label, string $image)
  109. //
  110. //    Description:
  111. //        Set the image for the panel configuration specified by the label
  112. //        argument.
  113. //
  114. //        If the image argument is an empty string then the panel configuration
  115. //        will revert to using the default image.
  116. //
  117. //    Arguments:
  118. //        $label - The panel configuration label.
  119. //
  120. //        $image - The new image.
  121. //
  122. {
  123.     string $panelConfiguration, $defaultImage;
  124.  
  125.     $panelConfiguration = `getPanel -configWithLabel $label`;
  126.  
  127.     if ("" != $panelConfiguration) {
  128.         $defaultImage = `panelConfiguration -query -defaultImage $panelConfiguration`;
  129.         if ($image == $defaultImage) {
  130.             $image = "";
  131.         }
  132.         panelConfiguration -edit -image $image $panelConfiguration;
  133.  
  134.     } else {
  135.         error ("A panel configuration named \"" + $label + "\" does not exist.");
  136.     }
  137. }
  138.  
  139. proc createToolbox(string $parent)
  140. //
  141. //    Description:
  142. //        Create the Toolbox.
  143. //
  144. //    Arguments:
  145. //        parent - The parent layout for the Panel Toolbox.
  146. //
  147. {
  148.     global string $gSelect;
  149.  
  150.     global int    $kNumberOfQuickLayoutButtons = 6;
  151.  
  152.     global int    $kQuickLayoutInfoArrayElementSize = 3;
  153.     global int    $kImageIndex      = 0;
  154.     global int    $kCommandIndex    = 1;
  155.     global int    $kAnnotationIndex = 2;
  156.  
  157.     global int    $kContentFrameSize  = 16;
  158.  
  159.     global string $gToolBox;
  160.     global string $gSelect;
  161.     global string $gLasso;
  162.     global string $gRotate;
  163.     global string $gScale;
  164.     global string $gshowManip;
  165.     global string $gNonSacredToolWidget;
  166.     global string $gCurrentSacredTool;
  167.  
  168.     string $toolBox;
  169.  
  170.     string $contentForm, $contentFrameArray[4], $contentDropArrow, $popupMenu;
  171.     string $savedLayoutsPopupMenu, $layout, $layoutArray[], $layoutName;
  172.     string $quickLayoutsForm , $quickLayoutsForm;
  173.     string $quickButtonArray[], $quickDropDownArray[];
  174.     int    $index;
  175.  
  176.     // ----------------------------------------------------------------------
  177.     //
  178.     //    The tools, eg. Select, Move, Rotate, Scale, etc.
  179.     //    
  180.     setParent $parent;
  181.  
  182.     $toolBox = `frameLayout
  183.         -borderVisible true
  184.         -borderStyle   "in"
  185.         -labelVisible  false
  186.         -collapse      false
  187.         -collapsable   false`;
  188.     
  189.     $gToolBox = `gridLayout
  190.         -numberOfRowsColumns 7 1
  191.         -autoGrow            false
  192.         -width               34
  193.         -cellWidthHeight     34 34`;
  194.  
  195.     //    Get the tool collection.
  196.     //
  197.     if (!`toolCollection -exists toolCluster`) {
  198.         toolCollection -global true toolCluster;
  199.     }
  200.  
  201.     //    Create the tool buttons.
  202.     //
  203.     toolButton
  204.         -doubleClickCommand  toolPropertyWindow 
  205.         -tool                $gSelect
  206.         -image1              "aselect.xpm"
  207.         selectTool;
  208.     
  209.     toolButton
  210.         -doubleClickCommand  toolPropertyWindow 
  211.         -tool                $gLasso
  212.         -image1              "lassoSelect.xpm"
  213.         lassoTool;
  214.     
  215.        toolButton
  216.         -doubleClickCommand  toolPropertyWindow
  217.         -tool                moveSuperContext
  218.         -image1              "move_M.xpm"
  219.         moveTool;
  220.  
  221.     toolButton
  222.         -doubleClickCommand  toolPropertyWindow
  223.         -tool                $gRotate 
  224.         -image1              "rotate_M.xpm"
  225.         rotateTool;
  226.  
  227.     toolButton
  228.         -doubleClickCommand  toolPropertyWindow
  229.         -tool                $gScale 
  230.         -image1              "scale_M.xpm"
  231.         scaleTool;
  232.  
  233.     toolButton
  234.         -doubleClickCommand  toolPropertyWindow
  235.         -tool                $gshowManip 
  236.         -image1              "showManip.xpm"
  237.         showManipTool;
  238.  
  239.     $gNonSacredToolWidget = `toolButton
  240.         -doubleClickCommand toolPropertyWindow`;
  241.  
  242.     //    Select the current tool.
  243.     //
  244.     if (`toolButton -exists selectTool`) {
  245.         setToolTo $gSelect;
  246.         $gCurrentSacredTool = $gSelect;
  247.     }
  248.  
  249.     // ----------------------------------------------------------------------
  250.     //
  251.     //    Create the panel control area.
  252.     //
  253.  
  254.     setParent $parent;
  255.  
  256.     $panelBoxFrame = `frameLayout 
  257.         -borderVisible true
  258.         -borderStyle   "in"
  259.         -labelVisible  false
  260.         -collapse      false
  261.         -collapsable   false`;
  262.     
  263.     $panelBox = `gridLayout    
  264.         -numberOfRowsColumns ($kNumberOfQuickLayoutButtons + 1) 1
  265.         -autoGrow            false
  266.         -width               34
  267.         -cellWidthHeight     34 34
  268.         ToolboxConfigurationGrid`;
  269.  
  270.     // ----------------------------------------------------------------------
  271.     //
  272.     //    Quick layout access controls.
  273.     //
  274.     //    A group of controls that allows the user to quickly switch between
  275.     //    saved panel layouts.
  276.     //
  277.     //    There are a limited number of these quick access controls but each
  278.     //    can be set to show any saved layout.
  279.     //
  280.  
  281.     for ($index = 0; $index < $kNumberOfQuickLayoutButtons; $index ++) {
  282.         $quickButtonArray[$index] = `iconTextButton
  283.             -image1 "vacantCell.xpm" -width 34 -height 34`;
  284.     }
  285.  
  286.     //    Add popup menus to the quick layout buttons.
  287.     //
  288.     for ($index = 0; $index < $kNumberOfQuickLayoutButtons; $index ++) {
  289.         $popupMenu = `popupMenu -parent $quickButtonArray[$index] -button 3`; 
  290.         popupMenu -edit
  291.             -postMenuCommand ("toolboxCreateQuickLayoutPopupMenuItems " 
  292.                 + $popupMenu + " " + $index)
  293.             $popupMenu;
  294.     }
  295.  
  296.     // ----------------------------------------------------------------------
  297.     //
  298.     //    Panel configuration and content.
  299.     //    
  300.     //    A group of controls that mirror the current panel
  301.     //    configuration in the main Maya window. By clicking on one of the
  302.     //    panel buttons the user will be presented with a popup menu of 
  303.     //    panel names. Selecting an item from the popup menu will show that
  304.     //    panel in the corresponding position in the main window.
  305.     //
  306.     
  307.     setParent $panelBox;
  308.     
  309.     $contentForm = `formLayout ToolboxConfigurationForm`;
  310.  
  311.     $contentFrameArray[0] = `frameLayout -labelVisible false -borderStyle "out" 
  312.         -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame0`;
  313.     string $contentButton1 = `iconTextStaticLabel -image1 "dropArrowSmall.xpm" -width 10 -height 8`;
  314.     setParent ..;
  315.  
  316.     $contentFrameArray[1] = `frameLayout -labelVisible false -borderStyle "out" 
  317.         -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame1`;
  318.     string $contentButton2 = `iconTextStaticLabel -image1 "dropArrowSmall.xpm" -width 10 -height 8`;
  319.     setParent ..;
  320.  
  321.     $contentFrameArray[2] = `frameLayout -labelVisible false -borderStyle "out" 
  322.         -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame2`;
  323.     string $contentButton3 = `iconTextStaticLabel -image1 "dropArrowSmall.xpm" -width 10 -height 8`;
  324.     setParent ..;
  325.  
  326.     $contentFrameArray[3] = `frameLayout -labelVisible false -borderStyle "out" 
  327.         -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame3`;
  328.     string $contentButton4 = `iconTextStaticLabel -image1 "dropArrowSmall.xpm" -width 10 -height 8`;
  329.     setParent ..;
  330.  
  331.     //
  332.     //    Add popup menus containing names of panels to the panel content frames.
  333.     //
  334.     for ($index = 0; $index < size($contentFrameArray); $index++) {
  335.         $popupMenu = `popupMenu -parent $contentFrameArray[$index] -button 1`;
  336.         popupMenu -edit
  337.             -postMenuCommand ("toolboxCreatePanelContentPopupMenuItems " 
  338.                 + $popupMenu + " " + $index)
  339.             $popupMenu;
  340.     }
  341.  
  342.     //    Create menu items for configuration popup menu.
  343.     //    If we create just one popup menu for the parent form,
  344.     //    the popup works but the special "right-click" cursor
  345.     //    does not necessarily show. So we assign a popup to the buttons.
  346.     //
  347.     createConfigurationPopupMenu($contentButton1);
  348.     createConfigurationPopupMenu($contentButton2);
  349.     createConfigurationPopupMenu($contentButton3);
  350.     createConfigurationPopupMenu($contentButton4);
  351.  
  352.     setParent $parent;
  353.     string $iconName;
  354.     if(`about -mac`) {
  355.         $iconName = "mayaIconAqua.xpm";
  356.     } else {
  357.         $iconName = "mayaIcon.xpm";
  358.     }
  359.     
  360.     string $mayaIconButton = `iconTextButton
  361.             -image1 $iconName -width 34 -height 34
  362.             -command "showHelp -absolute \"http://www.aliaswavefront.com/maya/news\""`;
  363.     // ----------------------------------------------------------------------
  364.     //
  365.     //    Top level attachments.
  366.     //
  367.     formLayout -edit
  368.         -attachForm     $toolBox            "top"    0
  369.         -attachForm     $toolBox            "left"   0
  370.         -attachNone     $toolBox            "bottom"
  371.         -attachNone     $toolBox            "right"
  372.  
  373.         -attachControl  $panelBoxFrame        "top"    4 $toolBox
  374.         -attachForm     $panelBoxFrame        "left"   0
  375.         -attachNone     $panelBoxFrame        "bottom"
  376.         -attachNone     $panelBoxFrame        "right"
  377.  
  378.         -attachNone $mayaIconButton "top"
  379.         -attachForm $mayaIconButton "left" 2
  380.         -attachNone $mayaIconButton "right"
  381.         -attachForm $mayaIconButton "bottom" 2
  382.  
  383.         $parent;
  384.  
  385.     //
  386.     //    Get the quick layout button preferences. Create defaults if necessary.
  387.     //
  388.     if (!`optionVar -exists quickPanelButtonLayout`) {
  389.         optionVar
  390.             -stringValueAppend quickPanelButtonLayout "Single Perspective View"
  391.             -stringValueAppend quickPanelButtonLayout "Four View"
  392.             -stringValueAppend quickPanelButtonLayout "Persp/Outliner"
  393.             -stringValueAppend quickPanelButtonLayout "Persp/Graph"
  394.             -stringValueAppend quickPanelButtonLayout "Hypershade/Persp"
  395.             -stringValueAppend quickPanelButtonLayout "Persp/Graph/Hypergraph";
  396.     }
  397. }
  398.  
  399. proc updatePaneConfiguration(string $configuration)
  400. //
  401. //    Description:
  402. //        Update the configuration buttons. Given the configuration argument
  403. //        arrange the buttons so that they match the arrangement.
  404. //
  405. //    Arguments:
  406. //        configuration - A pane configuration. Valid values are the same as 
  407. //                        those accepted by the 'paneLayout -edit -configuration'
  408. //                        command.
  409. //
  410. //                        Values currently handled are:
  411. //
  412. //                            single
  413. //                            vertical2
  414. //                            horizontal2
  415. //                            top3
  416. //                            left3
  417. //                            bottom3
  418. //                            right3
  419. //                            quad
  420. //
  421. {
  422.     global int $kContentFrameSize;
  423.  
  424.     if ("" == $configuration) {
  425.         error -showLineNumber true ("Argument must not be empty string.");
  426.         return;
  427.     }
  428.  
  429.     string $formLayout = "ToolboxConfigurationForm";
  430.  
  431.     //    Reset the attachments before setting the correct ones. This fixes up a 
  432.     //    widget postion negotiation problem on Motif.
  433.     //
  434.     int $offset = 1;
  435.     formLayout -edit
  436.         -attachForm     ToolboxContentFrame0 "top"    0
  437.         -attachForm     ToolboxContentFrame0 "left"   $offset
  438.         -attachNone     ToolboxContentFrame0 "bottom"
  439.         -attachNone     ToolboxContentFrame0 "right"
  440.  
  441.         -attachForm     ToolboxContentFrame1 "top"    0
  442.         -attachForm     ToolboxContentFrame1 "left"   $offset
  443.         -attachNone     ToolboxContentFrame1 "bottom"
  444.         -attachNone     ToolboxContentFrame1 "right"
  445.  
  446.         -attachForm     ToolboxContentFrame2 "top"    0
  447.         -attachForm     ToolboxContentFrame2 "left"   $offset
  448.         -attachNone     ToolboxContentFrame2 "bottom"
  449.         -attachNone     ToolboxContentFrame2 "right"
  450.  
  451.         -attachForm     ToolboxContentFrame3 "top"    0
  452.         -attachForm     ToolboxContentFrame3 "left"   $offset
  453.         -attachNone     ToolboxContentFrame3 "bottom"
  454.         -attachNone     ToolboxContentFrame3 "right"
  455.         $formLayout;
  456.  
  457.     switch ($configuration) {
  458.         case "single":
  459.             frameLayout -edit -visible true  -width (2 * $kContentFrameSize) -height (2 * $kContentFrameSize) ToolboxContentFrame0;
  460.             frameLayout -edit -visible false ToolboxContentFrame1;
  461.             frameLayout -edit -visible false ToolboxContentFrame2;
  462.             frameLayout -edit -visible false ToolboxContentFrame3;
  463.             formLayout -edit
  464.                 -attachForm     ToolboxContentFrame0 "top"    0
  465.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  466.                 -attachNone     ToolboxContentFrame0 "bottom"
  467.                 -attachNone     ToolboxContentFrame0 "right"
  468.  
  469.                 -attachNone     ToolboxContentFrame1 "top"
  470.                 -attachNone     ToolboxContentFrame1 "left"
  471.                 -attachNone     ToolboxContentFrame1 "bottom"
  472.                 -attachNone     ToolboxContentFrame1 "right"
  473.  
  474.                 -attachNone     ToolboxContentFrame2 "top"
  475.                 -attachNone     ToolboxContentFrame2 "left"
  476.                 -attachNone     ToolboxContentFrame2 "bottom"
  477.                 -attachNone     ToolboxContentFrame2 "right"
  478.  
  479.                 -attachNone     ToolboxContentFrame3 "top"
  480.                 -attachNone     ToolboxContentFrame3 "left"
  481.                 -attachNone     ToolboxContentFrame3 "bottom"
  482.                 -attachNone     ToolboxContentFrame3 "right"
  483.                 $formLayout; 
  484.             break;
  485.  
  486.         case "vertical2":
  487.             frameLayout -edit -visible true  -width $kContentFrameSize -height (2 * $kContentFrameSize) ToolboxContentFrame0;
  488.             frameLayout -edit -visible true  -width $kContentFrameSize -height (2 * $kContentFrameSize) ToolboxContentFrame1;
  489.             frameLayout -edit -visible false ToolboxContentFrame2;
  490.             frameLayout -edit -visible false ToolboxContentFrame3;
  491.             formLayout -edit
  492.                 -attachForm     ToolboxContentFrame0 "top"    0
  493.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  494.                 -attachNone     ToolboxContentFrame0 "bottom"
  495.                 -attachNone     ToolboxContentFrame0 "right"
  496.  
  497.                 -attachForm     ToolboxContentFrame1 "top"    0
  498.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + $kContentFrameSize)
  499.                 -attachNone     ToolboxContentFrame1 "bottom"
  500.                 -attachNone     ToolboxContentFrame1 "right"
  501.  
  502.                 -attachNone     ToolboxContentFrame2 "top"
  503.                 -attachNone     ToolboxContentFrame2 "left"
  504.                 -attachNone     ToolboxContentFrame2 "bottom"
  505.                 -attachNone     ToolboxContentFrame2 "right"
  506.  
  507.                 -attachNone     ToolboxContentFrame3 "top"
  508.                 -attachNone     ToolboxContentFrame3 "left"
  509.                 -attachNone     ToolboxContentFrame3 "bottom"
  510.                 -attachNone     ToolboxContentFrame3 "right"
  511.                 $formLayout; 
  512.             break;
  513.  
  514.         case "horizontal2":
  515.             frameLayout -edit -visible true  -width (2 * $kContentFrameSize) -height $kContentFrameSize ToolboxContentFrame0;
  516.             frameLayout -edit -visible true  -width (2 * $kContentFrameSize) -height $kContentFrameSize ToolboxContentFrame1;
  517.             frameLayout -edit -visible false ToolboxContentFrame2;
  518.             frameLayout -edit -visible false ToolboxContentFrame3;
  519.             formLayout -edit
  520.                 -attachForm     ToolboxContentFrame0 "top"    0
  521.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  522.                 -attachNone     ToolboxContentFrame0 "bottom"
  523.                 -attachNone     ToolboxContentFrame0 "right"
  524.  
  525.                 -attachForm     ToolboxContentFrame1 "top"    $kContentFrameSize
  526.                 -attachForm     ToolboxContentFrame1 "left"   $offset
  527.                 -attachNone     ToolboxContentFrame1 "bottom"
  528.                 -attachNone     ToolboxContentFrame1 "right"
  529.  
  530.                 -attachNone     ToolboxContentFrame2 "top"
  531.                 -attachNone     ToolboxContentFrame2 "left"
  532.                 -attachNone     ToolboxContentFrame2 "bottom"
  533.                 -attachNone     ToolboxContentFrame2 "right"
  534.  
  535.                 -attachNone     ToolboxContentFrame3 "top"
  536.                 -attachNone     ToolboxContentFrame3 "left"
  537.                 -attachNone     ToolboxContentFrame3 "bottom"
  538.                 -attachNone     ToolboxContentFrame3 "right"
  539.                 $formLayout;
  540.             break;
  541.  
  542.         case "top3":
  543.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame0;
  544.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame1;
  545.             frameLayout -edit -visible true  -width (2 * $kContentFrameSize) -height $kContentFrameSize ToolboxContentFrame2;
  546.             frameLayout -edit -visible false ToolboxContentFrame3;
  547.             formLayout -edit
  548.                 -attachForm     ToolboxContentFrame0 "top"    0
  549.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  550.                 -attachNone     ToolboxContentFrame0 "bottom"
  551.                 -attachNone     ToolboxContentFrame0 "right"
  552.  
  553.                 -attachForm     ToolboxContentFrame1 "top"    0
  554.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + $kContentFrameSize)
  555.                 -attachNone     ToolboxContentFrame1 "bottom"
  556.                 -attachNone     ToolboxContentFrame1 "right"
  557.  
  558.                 -attachForm     ToolboxContentFrame2 "top"    $kContentFrameSize
  559.                 -attachForm     ToolboxContentFrame2 "left"   $offset
  560.                 -attachNone     ToolboxContentFrame2 "bottom"
  561.                 -attachNone     ToolboxContentFrame2 "right"
  562.  
  563.                 -attachNone     ToolboxContentFrame3 "top"
  564.                 -attachNone     ToolboxContentFrame3 "left"
  565.                 -attachNone     ToolboxContentFrame3 "bottom"
  566.                 -attachNone     ToolboxContentFrame3 "right"
  567.                 $formLayout;
  568.             break;
  569.  
  570.         case "left3": 
  571.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame0;
  572.             frameLayout -edit -visible true  -width $kContentFrameSize -height (2 * $kContentFrameSize) ToolboxContentFrame1;
  573.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame2;
  574.             frameLayout -edit -visible false ToolboxContentFrame3;
  575.             formLayout -edit
  576.                 -attachForm     ToolboxContentFrame0 "top"    0
  577.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  578.                 -attachNone     ToolboxContentFrame0 "bottom"
  579.                 -attachNone     ToolboxContentFrame0 "right"
  580.  
  581.                 -attachForm     ToolboxContentFrame1 "top"    0
  582.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + $kContentFrameSize)
  583.                 -attachNone     ToolboxContentFrame1 "bottom"
  584.                 -attachNone     ToolboxContentFrame1 "right"
  585.  
  586.                 -attachForm     ToolboxContentFrame2 "top"    $kContentFrameSize
  587.                 -attachForm     ToolboxContentFrame2 "left"   $offset
  588.                 -attachNone     ToolboxContentFrame2 "bottom"
  589.                 -attachNone     ToolboxContentFrame2 "right"
  590.  
  591.                 -attachNone     ToolboxContentFrame3 "top"
  592.                 -attachNone     ToolboxContentFrame3 "left"
  593.                 -attachNone     ToolboxContentFrame3 "bottom"
  594.                 -attachNone     ToolboxContentFrame3 "right"
  595.                 $formLayout;
  596.             break;
  597.  
  598.         case "bottom3": 
  599.             frameLayout -edit -visible true  -width (2 * $kContentFrameSize) -height $kContentFrameSize ToolboxContentFrame0;
  600.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame1;
  601.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame2;
  602.             frameLayout -edit -visible false ToolboxContentFrame3;
  603.             formLayout -edit
  604.                 -attachForm     ToolboxContentFrame0 "top"    0
  605.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  606.                 -attachNone     ToolboxContentFrame0 "bottom"
  607.                 -attachNone     ToolboxContentFrame0 "right"
  608.  
  609.                 -attachForm     ToolboxContentFrame1 "top"    $kContentFrameSize
  610.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + $kContentFrameSize)
  611.                 -attachNone     ToolboxContentFrame1 "bottom"
  612.                 -attachNone     ToolboxContentFrame1 "right"
  613.  
  614.                 -attachForm     ToolboxContentFrame2 "top"    $kContentFrameSize
  615.                 -attachForm     ToolboxContentFrame2 "left"   $offset
  616.                 -attachNone     ToolboxContentFrame2 "bottom"
  617.                 -attachNone     ToolboxContentFrame2 "right"
  618.  
  619.                 -attachNone     ToolboxContentFrame3 "top"
  620.                 -attachNone     ToolboxContentFrame3 "left"
  621.                 -attachNone     ToolboxContentFrame3 "bottom"
  622.                 -attachNone     ToolboxContentFrame3 "right"
  623.                 $formLayout;
  624.             break;
  625.  
  626.         case "right3": 
  627.             frameLayout -edit -visible true  -width $kContentFrameSize -height (2 * $kContentFrameSize) ToolboxContentFrame0;
  628.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame1;
  629.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame2;
  630.             frameLayout -edit -visible false ToolboxContentFrame3;
  631.             formLayout -edit
  632.                 -attachForm     ToolboxContentFrame0 "top"    0
  633.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  634.                 -attachNone     ToolboxContentFrame0 "bottom"
  635.                 -attachNone     ToolboxContentFrame0 "right"
  636.  
  637.                 -attachForm     ToolboxContentFrame1 "top"    0
  638.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + $kContentFrameSize)
  639.                 -attachNone     ToolboxContentFrame1 "bottom"
  640.                 -attachNone     ToolboxContentFrame1 "right"
  641.  
  642.                 -attachForm     ToolboxContentFrame2 "top"    $kContentFrameSize
  643.                 -attachForm     ToolboxContentFrame2 "left"   ($offset + $kContentFrameSize)
  644.                 -attachNone     ToolboxContentFrame2 "bottom"
  645.                 -attachNone     ToolboxContentFrame2 "right"
  646.  
  647.                 -attachNone     ToolboxContentFrame3 "top"
  648.                 -attachNone     ToolboxContentFrame3 "left"
  649.                 -attachNone     ToolboxContentFrame3 "bottom"
  650.                 -attachNone     ToolboxContentFrame3 "right"
  651.                 $formLayout;
  652.             break;
  653.  
  654.         case "horizontal3":
  655.             frameLayout -edit -visible true
  656.                 -width  (2 * $kContentFrameSize)
  657.                 -height (2 * $kContentFrameSize / 3)
  658.                 ToolboxContentFrame0;
  659.             frameLayout -edit -visible true
  660.                 -width  (2 * $kContentFrameSize)
  661.                 -height (2 * $kContentFrameSize / 3)
  662.                 ToolboxContentFrame1;
  663.             frameLayout -edit -visible true
  664.                 -width  (2 * $kContentFrameSize)
  665.                 -height (2 * $kContentFrameSize / 3)
  666.                 ToolboxContentFrame2;
  667.             frameLayout -edit -visible false ToolboxContentFrame3;
  668.  
  669.             formLayout -edit
  670.                 -attachForm     ToolboxContentFrame0 "top"    0
  671.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  672.                 -attachNone     ToolboxContentFrame0 "bottom"
  673.                 -attachNone     ToolboxContentFrame0 "right"
  674.  
  675.                 -attachForm     ToolboxContentFrame1 "top"    (2 * $kContentFrameSize / 3)
  676.                 -attachForm     ToolboxContentFrame1 "left"   $offset
  677.                 -attachNone     ToolboxContentFrame1 "bottom"
  678.                 -attachNone     ToolboxContentFrame1 "right"
  679.  
  680.                 -attachForm     ToolboxContentFrame2 "top"    (4 * $kContentFrameSize / 3)
  681.                 -attachForm     ToolboxContentFrame2 "left"   $offset
  682.                 -attachNone     ToolboxContentFrame2 "bottom"
  683.                 -attachNone     ToolboxContentFrame2 "right"
  684.  
  685.                 -attachNone     ToolboxContentFrame3 "top"
  686.                 -attachNone     ToolboxContentFrame3 "left"
  687.                 -attachNone     ToolboxContentFrame3 "bottom"
  688.                 -attachNone     ToolboxContentFrame3 "right"
  689.                 $formLayout;
  690.             break;
  691.  
  692.         case "vertical3":
  693.             frameLayout -edit -visible true
  694.                 -width (2 * $kContentFrameSize / 3)
  695.                 -height ($kContentFrameSize * 2)
  696.                 ToolboxContentFrame0;
  697.             frameLayout -edit -visible true
  698.                 -width (2 * $kContentFrameSize / 3)
  699.                 -height ($kContentFrameSize * 2)
  700.                 ToolboxContentFrame1;
  701.             frameLayout -edit -visible true
  702.                 -width (2 * $kContentFrameSize / 3)
  703.                 -height ($kContentFrameSize * 2)
  704.                 ToolboxContentFrame2;
  705.             frameLayout -edit -visible false ToolboxContentFrame3;
  706.  
  707.             formLayout -edit
  708.                 -attachForm     ToolboxContentFrame0 "top"    0
  709.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  710.                 -attachNone     ToolboxContentFrame0 "bottom"
  711.                 -attachNone     ToolboxContentFrame0 "right"
  712.  
  713.                 -attachForm     ToolboxContentFrame1 "top"    0
  714.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + 2 * $kContentFrameSize / 3)
  715.                 -attachNone     ToolboxContentFrame1 "bottom"
  716.                 -attachNone     ToolboxContentFrame1 "right"
  717.  
  718.                 -attachForm     ToolboxContentFrame2 "top"    0
  719.                 -attachForm     ToolboxContentFrame2 "left"   ($offset + 4 * $kContentFrameSize / 3)
  720.                 -attachNone     ToolboxContentFrame2 "bottom"
  721.                 -attachNone     ToolboxContentFrame2 "right"
  722.  
  723.                 -attachNone     ToolboxContentFrame3 "top"
  724.                 -attachNone     ToolboxContentFrame3 "left"
  725.                 -attachNone     ToolboxContentFrame3 "bottom"
  726.                 -attachNone     ToolboxContentFrame3 "right"
  727.                 $formLayout;
  728.             break;
  729.  
  730.         case "quad":
  731.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame0;
  732.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame1;
  733.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame2;
  734.             frameLayout -edit -visible true  -width $kContentFrameSize -height $kContentFrameSize ToolboxContentFrame3;
  735.             formLayout -edit
  736.                 -attachForm     ToolboxContentFrame0 "top"    0
  737.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  738.                 -attachNone     ToolboxContentFrame0 "bottom"
  739.                 -attachNone     ToolboxContentFrame0 "right"
  740.  
  741.                 -attachForm     ToolboxContentFrame1 "top"    0
  742.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + $kContentFrameSize)
  743.                 -attachNone     ToolboxContentFrame1 "bottom"
  744.                 -attachNone     ToolboxContentFrame1 "right"
  745.  
  746.                 -attachForm     ToolboxContentFrame2 "top"    $kContentFrameSize
  747.                 -attachForm     ToolboxContentFrame2 "left"   ($offset + $kContentFrameSize)
  748.                 -attachNone     ToolboxContentFrame2 "bottom"
  749.                 -attachNone     ToolboxContentFrame2 "right"
  750.  
  751.                 -attachForm     ToolboxContentFrame3 "top"    $kContentFrameSize
  752.                 -attachForm     ToolboxContentFrame3 "left"   $offset
  753.                 -attachNone     ToolboxContentFrame3 "bottom"
  754.                 -attachNone     ToolboxContentFrame3 "right"
  755.                 $formLayout;
  756.             break;
  757.  
  758.         case "top4":
  759.             frameLayout -edit -visible true
  760.                 -width (2 * $kContentFrameSize / 3)
  761.                 -height $kContentFrameSize
  762.                 ToolboxContentFrame0;
  763.             frameLayout -edit -visible true
  764.                 -width (2 * $kContentFrameSize / 3)
  765.                 -height $kContentFrameSize
  766.                 ToolboxContentFrame1;
  767.             frameLayout -edit -visible true
  768.                 -width (2 * $kContentFrameSize / 3)
  769.                 -height $kContentFrameSize
  770.                 ToolboxContentFrame2;
  771.             frameLayout -edit -visible true
  772.                 -width (2 * $kContentFrameSize)
  773.                 -height $kContentFrameSize
  774.                 ToolboxContentFrame3;
  775.             formLayout -edit
  776.                 -attachForm     ToolboxContentFrame0 "top"    0
  777.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  778.                 -attachNone     ToolboxContentFrame0 "bottom"
  779.                 -attachNone     ToolboxContentFrame0 "right"
  780.  
  781.                 -attachForm     ToolboxContentFrame1 "top"    0
  782.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + 2 * $kContentFrameSize / 3)
  783.                 -attachNone     ToolboxContentFrame1 "bottom"
  784.                 -attachNone     ToolboxContentFrame1 "right"
  785.  
  786.                 -attachForm     ToolboxContentFrame2 "top"    0
  787.                 -attachForm     ToolboxContentFrame2 "left"   ($offset + 4 * $kContentFrameSize / 3)
  788.                 -attachNone     ToolboxContentFrame2 "bottom"
  789.                 -attachNone     ToolboxContentFrame2 "right"
  790.  
  791.                 -attachForm     ToolboxContentFrame3 "top"    $kContentFrameSize
  792.                 -attachForm     ToolboxContentFrame3 "left"   $offset
  793.                 -attachNone     ToolboxContentFrame3 "bottom"
  794.                 -attachNone     ToolboxContentFrame3 "right"
  795.                 $formLayout;
  796.             break;
  797.  
  798.         case "left4":
  799.             frameLayout -edit -visible true
  800.                 -width  $kContentFrameSize
  801.                 -height (2 * $kContentFrameSize / 3)
  802.                 ToolboxContentFrame0;
  803.             frameLayout -edit -visible true
  804.                 -width  $kContentFrameSize
  805.                 -height (2 * $kContentFrameSize)
  806.                 ToolboxContentFrame1;
  807.             frameLayout -edit -visible true
  808.                 -width  $kContentFrameSize
  809.                 -height (2 * $kContentFrameSize / 3)
  810.                 ToolboxContentFrame2;
  811.             frameLayout -edit -visible true
  812.                 -width  $kContentFrameSize
  813.                 -height (2 * $kContentFrameSize / 3)
  814.                 ToolboxContentFrame3;
  815.             formLayout -edit
  816.                 -attachForm     ToolboxContentFrame0 "top"    0
  817.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  818.                 -attachNone     ToolboxContentFrame0 "bottom"
  819.                 -attachNone     ToolboxContentFrame0 "right"
  820.  
  821.                 -attachForm     ToolboxContentFrame1 "top"    0
  822.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + $kContentFrameSize)
  823.                 -attachNone     ToolboxContentFrame1 "bottom"
  824.                 -attachNone     ToolboxContentFrame1 "right"
  825.  
  826.                 -attachForm     ToolboxContentFrame2 "top"    (4 * $kContentFrameSize / 3)
  827.                 -attachForm     ToolboxContentFrame2 "left"   $offset
  828.                 -attachNone     ToolboxContentFrame2 "bottom"
  829.                 -attachNone     ToolboxContentFrame2 "right"
  830.  
  831.                 -attachForm     ToolboxContentFrame3 "top"    (2 * $kContentFrameSize / 3)
  832.                 -attachForm     ToolboxContentFrame3 "left"   $offset
  833.                 -attachNone     ToolboxContentFrame3 "bottom"
  834.                 -attachNone     ToolboxContentFrame3 "right"
  835.                 $formLayout;
  836.             break;
  837.  
  838.         case "bottom4":
  839.             frameLayout -edit -visible true
  840.                 -width (2 * $kContentFrameSize)
  841.                 -height $kContentFrameSize
  842.                 ToolboxContentFrame0;
  843.             frameLayout -edit -visible true
  844.                 -width (2 * $kContentFrameSize / 3)
  845.                 -height $kContentFrameSize
  846.                 ToolboxContentFrame1;
  847.             frameLayout -edit -visible true
  848.                 -width (2 * $kContentFrameSize / 3)
  849.                 -height $kContentFrameSize
  850.                 ToolboxContentFrame2;
  851.             frameLayout -edit -visible true
  852.                 -width (2 * $kContentFrameSize / 3)
  853.                 -height $kContentFrameSize
  854.                 ToolboxContentFrame3;
  855.             formLayout -edit
  856.                 -attachForm     ToolboxContentFrame0 "top"    0
  857.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  858.                 -attachNone     ToolboxContentFrame0 "bottom"
  859.                 -attachNone     ToolboxContentFrame0 "right"
  860.  
  861.                 -attachForm     ToolboxContentFrame1 "top"    $kContentFrameSize
  862.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + 4 * $kContentFrameSize / 3)
  863.                 -attachNone     ToolboxContentFrame1 "bottom"
  864.                 -attachNone     ToolboxContentFrame1 "right"
  865.  
  866.                 -attachForm     ToolboxContentFrame2 "top"    $kContentFrameSize
  867.                 -attachForm     ToolboxContentFrame2 "left"   ($offset + 2 * $kContentFrameSize / 3)
  868.                 -attachNone     ToolboxContentFrame2 "bottom"
  869.                 -attachNone     ToolboxContentFrame2 "right"
  870.  
  871.                 -attachForm     ToolboxContentFrame3 "top"    $kContentFrameSize
  872.                 -attachForm     ToolboxContentFrame3 "left"   $offset
  873.                 -attachNone     ToolboxContentFrame3 "bottom"
  874.                 -attachNone     ToolboxContentFrame3 "right"
  875.                 $formLayout;
  876.             break;
  877.  
  878.         case "right4":
  879.             frameLayout -edit -visible true
  880.                 -width  $kContentFrameSize
  881.                 -height (2 * $kContentFrameSize)
  882.                 ToolboxContentFrame0;
  883.             frameLayout -edit -visible true
  884.                 -width  $kContentFrameSize
  885.                 -height (2 * $kContentFrameSize / 3)
  886.                 ToolboxContentFrame1;
  887.             frameLayout -edit -visible true
  888.                 -width  $kContentFrameSize
  889.                 -height (2 * $kContentFrameSize / 3)
  890.                 ToolboxContentFrame2;
  891.             frameLayout -edit -visible true
  892.                 -width  $kContentFrameSize
  893.                 -height (2 * $kContentFrameSize / 3)
  894.                 ToolboxContentFrame3;
  895.             formLayout -edit
  896.                 -attachForm     ToolboxContentFrame0 "top"    0
  897.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  898.                 -attachNone     ToolboxContentFrame0 "bottom"
  899.                 -attachNone     ToolboxContentFrame0 "right"
  900.  
  901.                 -attachForm     ToolboxContentFrame1 "top"    0
  902.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + $kContentFrameSize)
  903.                 -attachNone     ToolboxContentFrame1 "bottom"
  904.                 -attachNone     ToolboxContentFrame1 "right"
  905.  
  906.                 -attachForm     ToolboxContentFrame2 "top"    (2 * $kContentFrameSize / 3)
  907.                 -attachForm     ToolboxContentFrame2 "left"   ($offset + $kContentFrameSize)
  908.                 -attachNone     ToolboxContentFrame2 "bottom"
  909.                 -attachNone     ToolboxContentFrame2 "right"
  910.  
  911.                 -attachForm     ToolboxContentFrame3 "top"    (4 * $kContentFrameSize / 3)
  912.                 -attachForm     ToolboxContentFrame3 "left"   ($offset + $kContentFrameSize)
  913.                 -attachNone     ToolboxContentFrame3 "bottom"
  914.                 -attachNone     ToolboxContentFrame3 "right"
  915.                 $formLayout;
  916.             break;
  917.  
  918.         case "horizontal4":
  919.             frameLayout -edit -visible true
  920.                 -width  (2 * $kContentFrameSize)
  921.                 -height ($kContentFrameSize / 2)
  922.                 ToolboxContentFrame0;
  923.             frameLayout -edit -visible true
  924.                 -width  (2 * $kContentFrameSize)
  925.                 -height ($kContentFrameSize / 2)
  926.                 ToolboxContentFrame1;
  927.             frameLayout -edit -visible true
  928.                 -width  (2 * $kContentFrameSize)
  929.                 -height ($kContentFrameSize / 2)
  930.                 ToolboxContentFrame2;
  931.             frameLayout -edit -visible true
  932.                 -width  (2 * $kContentFrameSize)
  933.                 -height ($kContentFrameSize / 2)
  934.                 ToolboxContentFrame3;
  935.  
  936.             formLayout -edit
  937.                 -attachForm     ToolboxContentFrame0 "top"    0
  938.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  939.                 -attachNone     ToolboxContentFrame0 "bottom"
  940.                 -attachNone     ToolboxContentFrame0 "right"
  941.  
  942.                 -attachForm     ToolboxContentFrame1 "top"    ($kContentFrameSize / 2)
  943.                 -attachForm     ToolboxContentFrame1 "left"   $offset
  944.                 -attachNone     ToolboxContentFrame1 "bottom"
  945.                 -attachNone     ToolboxContentFrame1 "right"
  946.  
  947.                 -attachForm     ToolboxContentFrame2 "top"    $kContentFrameSize
  948.                 -attachForm     ToolboxContentFrame2 "left"   $offset
  949.                 -attachNone     ToolboxContentFrame2 "bottom"
  950.                 -attachNone     ToolboxContentFrame2 "right"
  951.  
  952.                 -attachForm     ToolboxContentFrame3 "top"    (3 * $kContentFrameSize / 2)
  953.                 -attachForm     ToolboxContentFrame3 "left"   $offset
  954.                 -attachNone     ToolboxContentFrame3 "bottom"
  955.                 -attachNone     ToolboxContentFrame3 "right"
  956.                 $formLayout;
  957.             break;
  958.  
  959.         case "vertical4":
  960.             frameLayout -edit -visible true
  961.                 -width ($kContentFrameSize / 2)
  962.                 -height ($kContentFrameSize * 2)
  963.                 ToolboxContentFrame0;
  964.             frameLayout -edit -visible true
  965.                 -width ($kContentFrameSize / 2)
  966.                 -height ($kContentFrameSize * 2)
  967.                 ToolboxContentFrame1;
  968.             frameLayout -edit -visible true
  969.                 -width ($kContentFrameSize / 2)
  970.                 -height ($kContentFrameSize * 2)
  971.                 ToolboxContentFrame2;
  972.             frameLayout -edit -visible true
  973.                 -width ($kContentFrameSize / 2)
  974.                 -height ($kContentFrameSize * 2)
  975.                 ToolboxContentFrame3;
  976.  
  977.             formLayout -edit
  978.                 -attachForm     ToolboxContentFrame0 "top"    0
  979.                 -attachForm     ToolboxContentFrame0 "left"   $offset
  980.                 -attachNone     ToolboxContentFrame0 "bottom"
  981.                 -attachNone     ToolboxContentFrame0 "right"
  982.  
  983.                 -attachForm     ToolboxContentFrame1 "top"    0
  984.                 -attachForm     ToolboxContentFrame1 "left"   ($offset + $kContentFrameSize / 2)
  985.                 -attachNone     ToolboxContentFrame1 "bottom"
  986.                 -attachNone     ToolboxContentFrame1 "right"
  987.  
  988.                 -attachForm     ToolboxContentFrame2 "top"    0
  989.                 -attachForm     ToolboxContentFrame2 "left"   ($offset + $kContentFrameSize)
  990.                 -attachNone     ToolboxContentFrame2 "bottom"
  991.                 -attachNone     ToolboxContentFrame2 "right"
  992.  
  993.                 -attachForm     ToolboxContentFrame3 "top"    0
  994.                 -attachForm     ToolboxContentFrame3 "left"   ($offset + 3 * $kContentFrameSize / 2)
  995.                 -attachNone     ToolboxContentFrame3 "bottom"
  996.                 -attachNone     ToolboxContentFrame3 "right"
  997.                 $formLayout;
  998.             break;
  999.  
  1000.         default:
  1001.             error -showLineNumber true ("Invalid argument: " + $configuration);
  1002.             break;
  1003.     }
  1004. }
  1005.  
  1006. global proc toolboxSaveCurrentLayout()
  1007. //
  1008. //    Description:
  1009. //        This procedure is called when the user wants to save the current 
  1010. //        layout configuration.
  1011. //
  1012. //        Set up a default image that corresponds to the current layout.
  1013. //
  1014. //        Prompt the user to enter a name for the layout.
  1015. //
  1016. {
  1017.     global string $gMainPane;
  1018.  
  1019.     string $image, $configuration, $panelConfiguration;
  1020.  
  1021.     //    Determine the current panel configuration.
  1022.     //
  1023.     $configuration = `paneLayout -query -configuration $gMainPane`;
  1024.  
  1025.     //    Get a default image that corresponds to the current panel configuration.
  1026.     //
  1027.     switch ($configuration) {
  1028.         case "single":
  1029.             $image = "defaultSingleLayout.xpm";
  1030.             break;
  1031.         case "horizontal2":
  1032.             $image = "defaultTwoStackedLayout.xpm";
  1033.             break;
  1034.         case "vertical2":
  1035.             $image = "defaultTwoSideBySideLayout.xpm";
  1036.             break;
  1037.         case "top3":
  1038.             $image = "defaultThreeSplitTopLayout.xpm";
  1039.             break;
  1040.         case "left3":
  1041.             $image = "defaultThreeSplitLeftLayout.xpm";
  1042.             break;
  1043.         case "bottom3":
  1044.             $image = "defaultThreeSplitBottomLayout.xpm";
  1045.             break;
  1046.         case "right3":
  1047.             $image = "defaultThreeSplitRightLayout.xpm";
  1048.             break;
  1049.         case "horizontal3":
  1050.             $image = "defaultThreeStackedLayout.xpm";
  1051.             break;
  1052.         case "vertical3":
  1053.             $image = "defaultThreeSideBySideLayout.xpm";
  1054.             break;
  1055.         case "quad":
  1056.             $image = "defaultFourQuadLayout.xpm";
  1057.             break;
  1058.         case "top4":
  1059.             $image = "defaultFourSplitTopLayout.xpm";
  1060.             break;
  1061.         case "left4":
  1062.             $image = "defaultFourSplitLeftLayout.xpm";
  1063.             break;
  1064.         case "bottom4":
  1065.             $image = "defaultFourSplitBottomLayout.xpm";
  1066.             break;
  1067.         case "right4":
  1068.             $image = "defaultFourSplitRightLayout.xpm";
  1069.             break;
  1070.         case "horizontal4":
  1071.             $image = "defaultFourStackedLayout.xpm";
  1072.             break;
  1073.         case "vertical4":
  1074.             $image = "defaultFourSideBySideLayout.xpm";
  1075.             break;
  1076.         default:
  1077.             $image = "vacantCell.xpm";
  1078.             break;
  1079.     }
  1080.  
  1081.     //    Prompt the user for a name to save the current layout.
  1082.     //    May return empty string.
  1083.     //
  1084.     string $layoutName = saveCurrentPanelLayout();
  1085.  
  1086.     if ("" != $layoutName) {
  1087.         //
  1088.         //    Save the image as the default.
  1089.         //
  1090.         $panelConfiguration = `getPanel -configWithLabel $layoutName`;
  1091.         if ("" != $panelConfiguration) {
  1092.             panelConfiguration -edit -defaultImage $image $panelConfiguration;
  1093.         }
  1094.     }
  1095. }
  1096.  
  1097. global proc toolboxCreatePanelContentPopupMenuItems(
  1098.     string $parent,
  1099.     int    $panelIndex)
  1100. //
  1101. //    Description:
  1102. //        This procedure is called when the panel content popup menu is
  1103. //        about to be shown.
  1104. //
  1105. //        Delete all the items in the menu and add the names of all the
  1106. //        panels.
  1107. //
  1108. //    Arguments:
  1109. //        parent - The popup menu parent for the menu items that will be 
  1110. //                 created in this procedure.
  1111. //
  1112. //        panelIndex - A 0-based index that specifies which panel in the
  1113. //                     configuration will be replaced with the selected
  1114. //                     panel. 0 is the top left panel and the indecies
  1115. //                     increment clockwise around the panel configuration.
  1116. //
  1117. {
  1118.     string $panels[], $visiblePanelArray[], $targetPanel;
  1119.     string $label, $type, $command;
  1120.     int    $enable, $index, $itemsPerDivider = 3;
  1121.  
  1122.     //    Determine the target panel, ie. the panel that is to be swapped
  1123.     //    out by the panel that was selected from the popup menu.
  1124.     //
  1125.     $visiblePanelArray = getVisiblePanels();
  1126.     $targetPanel = $visiblePanelArray[$panelIndex];
  1127.  
  1128.     //    Delete all the menu items in the popup menu.
  1129.     //
  1130.     popupMenu -edit -deleteAllItems $parent;
  1131.  
  1132.     //    Be sure to set the parent for the menu items.
  1133.     //
  1134.     setParent -menu $parent;
  1135.  
  1136.     //    Get a list of all the panels.
  1137.     //
  1138.     $panels = `getPanel -allPanels`;
  1139.  
  1140.     //    This index will be used to insert menu item dividers.
  1141.     //    Start counting at -4 because there are 4 model panels. When
  1142.     //    the index becomes 0 then add the first separator. For the
  1143.     //    rest of the panels add a separator every n panels, where
  1144.     //    n is set by $itemsPerDivider.
  1145.     //
  1146.     $index = -4;
  1147.  
  1148.     //    For each panel create a menu item in the popup menu.
  1149.     //
  1150.     //    Also set up the command for the menu item that will make panel 
  1151.     //    correpsonding to the menu item visible in the main window.
  1152.     //    
  1153.     for ($panel in $panels) {
  1154.         //
  1155.         //    Get all the panel information, ie. it's label and type. Then
  1156.         //    determine the command to attach to the menu item that will
  1157.         //    show that panel.
  1158.         //
  1159.         $type = `getPanel -typeOf $panel`;
  1160.         $label = `panel -query -label $panel`;
  1161.  
  1162.         //    Skip the Multilister. As of Maya 4.0 there should be no user
  1163.         //    interface for accessing this panel.
  1164.         //
  1165.         if ($label == "Multilister") {
  1166.             continue;
  1167.         }
  1168.  
  1169.         $command = ($type + " -edit -replacePanel " 
  1170.             + $targetPanel + " " + $panel);
  1171.  
  1172.         //    Add a separator after all the model panels and for every
  1173.         //    $itemsPerDivider items after that.
  1174.         //
  1175.         if (0 == $index || ($index > 0 && 0 == ($index % $itemsPerDivider))) {
  1176.             menuItem -divider true;
  1177.         }
  1178.  
  1179.         //    Determine if the panel is torn off. Disable the menu item if it is.
  1180.         //
  1181.         $enable = true;
  1182.         if (`panel -query -tearOff $panel`) {
  1183.             $enable = false;
  1184.         }
  1185.  
  1186.         //    Append to the command the procedure that will update the stated of
  1187.         //    the Toolbox to reflect the change.
  1188.         //
  1189.         menuItem -label $label -enable $enable 
  1190.             -command ($command + "; updateToolbox();");
  1191.  
  1192.         $index++;
  1193.     }
  1194. }
  1195.  
  1196. global proc toolboxCreateQuickLayoutPopupMenuItems(
  1197.     string $parent,
  1198.     int    $buttonIndex)
  1199. //
  1200. //    Description:
  1201. //        This procedure is called when the quick panel popup menu is
  1202. //        about to be shown.
  1203. //
  1204. //        Delete all the items in the menu and add the names of all the
  1205. //        saved panel layouts. Also add an item that allows the user to
  1206. //        change the image for the button.
  1207. //
  1208. //    Arguments:
  1209. //        parent - The popup menu parent for the menu items that will be 
  1210. //                 created in this procedure.
  1211. //
  1212. //        buttonIndex - A 0-based index corresponding to a quick access 
  1213. //                      layout button.
  1214. //
  1215. {
  1216.     string $layout, $layoutName, $layoutArray[];
  1217.  
  1218.     //    Delete all the menu items in the popup menu.
  1219.     //
  1220.     popupMenu -edit -deleteAllItems $parent;
  1221.  
  1222.     //    Set the parent for the menu items.
  1223.     //
  1224.     setParent -menu $parent;
  1225.  
  1226.     //    Add menu items.
  1227.     //
  1228.     $layoutArray = `getPanel -allConfigs`;
  1229.     for ($layout in $layoutArray) {
  1230.         $layoutName = `panelConfiguration -query -label $layout`;
  1231.         if ("Current Layout" != $layoutName) {
  1232.             menuItem -label $layoutName 
  1233.                 -command ("toolboxChangeQuickLayoutButton \"" + $layoutName 
  1234.                     + "\" " + $buttonIndex);
  1235.         }
  1236.     }
  1237.  
  1238.     //    Add an item that will save the current layout configuration.
  1239.     //
  1240.     menuItem -divider true;
  1241.     menuItem -label "Save Current Layout..." -command ("toolboxSaveCurrentLayout");
  1242.     menuItem -label "Edit Layouts..." -command ("PanelPreferencesWindow");
  1243.  
  1244.     //    Add an item that will show a window allowing the user to change the
  1245.     //    image on the quick access layout button.
  1246.     //
  1247.     menuItem -divider true;
  1248.     menuItem -label "Change Image..." 
  1249.         -command ("toolboxCreateQuickLayoutImageEditor " + $buttonIndex);
  1250. }
  1251.  
  1252. global proc toolboxChangeQuickLayoutButton(
  1253.     string $savedLayout,
  1254.     int    $buttonIndex)
  1255. //
  1256. //    Description:
  1257. //        This procedure is called whenever an item from a quick layout popup 
  1258. //        menu is selected. Update the corresponding button so that it will
  1259. //        now select the specified layout and show the appropriate image.
  1260. //
  1261. //    Arguments:
  1262. //        savedLayout - The saved layout name.
  1263. //
  1264. //        buttonIndex - 0 based index identifying a quick access button.
  1265. //
  1266. {
  1267.     string $layout, $layoutArray[], $image;
  1268.  
  1269.     //    Determine the current values of the quick access buttons.
  1270.     //
  1271.     $layoutArray = `optionVar -query quickPanelButtonLayout`;
  1272.  
  1273.     //    Set the new value for the appropriate button.
  1274.     //
  1275.     $layoutArray[$buttonIndex] = $savedLayout;
  1276.  
  1277.     //    Save the new value (along with the old).
  1278.     //
  1279.     //    Note: Is there an easier way to set just one value of a string array
  1280.     //    optionVar? The code below clears the entire pref array and then sets
  1281.     //    all the values.
  1282.     //
  1283.     optionVar -clearArray quickPanelButtonLayout;
  1284.     for ($layout in $layoutArray) {
  1285.         optionVar -stringValueAppend quickPanelButtonLayout $layout;
  1286.     }
  1287.  
  1288.     setNamedPanelLayout($savedLayout);
  1289.  
  1290.     updateToolbox();
  1291. }
  1292.  
  1293. global proc toolboxCreateQuickLayoutImageEditor(int $buttonIndex)
  1294. //
  1295. //    Description:
  1296. //        This procedure is called when the "Change Image..." menu item is
  1297. //        selected from a quick access layout button's popup menu.
  1298. //
  1299. //        Show a window that allows the user to select a default image or
  1300. //        browse for an image.
  1301. //
  1302. //    Arguments:
  1303. //        buttonIndex - 0 based index identifying a quick access button.
  1304. //
  1305. {
  1306.     string $window, $topForm, $bodyForm, $buttonForm;
  1307.     string $browseButton, $saveButton, $cancelButton;
  1308.     string $image, $tempImage, $configuration, $configurationArray[];
  1309.  
  1310.     string $defaultImages[] = {
  1311.         "defaultSingleLayout.xpm",
  1312.         "defaultTwoSideBySideLayout.xpm",
  1313.         "defaultTwoStackedLayout.xpm",
  1314.         "defaultThreeSplitTopLayout.xpm",
  1315.         "defaultThreeSplitLeftLayout.xpm",
  1316.         "defaultThreeSplitBottomLayout.xpm",
  1317.         "defaultThreeSplitRightLayout.xpm",
  1318.         "defaultThreeStackedLayout.xpm",
  1319.         "defaultThreeSideBySideLayout.xpm",
  1320.         "defaultFourQuadLayout.xpm",
  1321.         "defaultFourSplitTopLayout.xpm",
  1322.         "defaultFourSplitLeftLayout.xpm",
  1323.         "defaultFourSplitBottomLayout.xpm",
  1324.         "defaultFourSplitRightLayout.xpm",
  1325.         "defaultFourStackedLayout.xpm",
  1326.         "defaultFourSideBySideLayout.xpm"
  1327.         };
  1328.  
  1329.     //    Delete the window if it already exists.
  1330.     //
  1331.     if (`window -exists QuickLayoutImageEditor`) {
  1332.         deleteUI -window QuickLayoutImageEditor;
  1333.     }
  1334.  
  1335.     //    Get the array of quick access buttons.
  1336.     //
  1337.     $layoutArray = `optionVar -query quickPanelButtonLayout`;
  1338.  
  1339.     //    Determine the current image value of the quick access button.
  1340.     //
  1341.     $image = getQuickButtonImage($layoutArray[$buttonIndex]);
  1342.  
  1343.     //    Create the window and the top level layout.
  1344.     //
  1345.     $window = `window -title "Quick Layout Image Editor" -iconName "Edit Image" QuickLayoutImageEditor`;
  1346.  
  1347.     //    If a window pref doesn't exist then set a decent width. Otherwise, it will
  1348.     //    come up a little narrow.
  1349.     //
  1350.     if (!`windowPref -exists QuickLayoutImageEditor`) {
  1351.         window -edit -width 250 $window;
  1352.     }
  1353.  
  1354.     $topForm = `formLayout`;
  1355.     
  1356.     // ----------------------------------------------------------------------
  1357.     //
  1358.     //    Body.
  1359.     //
  1360.     setParent $topForm;
  1361.     $bodyForm = `formLayout`;
  1362.  
  1363.     $label = `text -label ($layoutArray[$buttonIndex])`;
  1364.  
  1365.     //    Create an icon control to show the current image.
  1366.     //
  1367.     $icon = `iconTextStaticLabel -width 34 -height 34 -image1 $image
  1368.         QuickLayoutImageEditorIcon`;
  1369.  
  1370.     $scrollLayout = `scrollLayout -childResizable true`;
  1371.     $list = `gridLayout -autoGrow true
  1372.         -columnsResizable true
  1373.         -allowEmptyCells false
  1374.         -cellWidthHeight 40 40`;
  1375.     
  1376.     $configurationArray = `getPanel -allConfigs`;
  1377.  
  1378.     //    Add menu items for the default panel configuration images.
  1379.     //
  1380.     for ($configuration in $configurationArray) {
  1381.         $tempImage = `panelConfiguration -query -defaultImage $configuration`;
  1382.  
  1383.         //    Don't list the image if it is the vacant cell image or a default
  1384.         //    image.
  1385.         //
  1386.         if ("" != $tempImage && $tempImage != "vacantCell.xpm"
  1387.             && (0 == AWNumberOfOccurrencesInStringArray($tempImage, $defaultImages))) {
  1388.             iconTextButton -parent $list -image1 $tempImage
  1389.                 -command ("iconTextStaticLabel -edit -image1 "
  1390.                     + $tempImage + " " + $icon);
  1391.         }
  1392.     }
  1393.     
  1394.     for ($tempImage in $defaultImages) {
  1395.         iconTextButton -parent $list -image1 $tempImage
  1396.             -command ("iconTextStaticLabel -edit -image1 "
  1397.                 + $tempImage + " " + $icon);
  1398.     }
  1399.  
  1400.     // ----------------------------------------------------------------------
  1401.     //
  1402.     //    Buttons.
  1403.     //
  1404.     setParent $topForm;
  1405.     $buttonForm = `formLayout -parent $topForm`;
  1406.  
  1407.     //    Save button.
  1408.     //
  1409.     $saveButton = `button -label "Save"
  1410.         -command ("toolboxSaveQuickLayoutImage " + $buttonIndex
  1411.             + "; toolboxCloseQuickLayoutImageEditor()")
  1412.         QuickLayoutImageEditorSaveButton`;
  1413.  
  1414.     //    Browse button.
  1415.     //
  1416.     $browseButton = `button -label "Browse..."
  1417.         -command ("bitmapBrowserWindow \"" + $image
  1418.             + "\" toolboxBrowserCallback")
  1419.         `;
  1420.  
  1421.     //    Cancel button.
  1422.     //
  1423.     $cancelButton = `button -label "Cancel"
  1424.         -command ("toolboxCloseQuickLayoutImageEditor()")`;
  1425.  
  1426.     formLayout -edit
  1427.         -attachForm     $icon         "top"    0
  1428.         -attachForm     $icon         "left"   0
  1429.         -attachNone     $icon         "bottom"
  1430.         -attachNone     $icon         "right"
  1431.  
  1432.         -attachForm     $label        "top"    8
  1433.         -attachControl  $label        "left"   6 $icon
  1434.         -attachNone     $label        "bottom"
  1435.         -attachNone     $label        "right"
  1436.  
  1437.         -attachControl  $scrollLayout "top"    6 $icon
  1438.         -attachForm     $scrollLayout "left"   0
  1439.         -attachForm     $scrollLayout "bottom" 0
  1440.         -attachForm     $scrollLayout "right"  0
  1441.         $bodyForm;
  1442.  
  1443.     formLayout -edit
  1444.         -attachForm     $saveButton    "top"    0
  1445.         -attachForm     $saveButton    "left"   0
  1446.         -attachForm     $saveButton    "bottom" 0
  1447.         -attachPosition $saveButton    "right"  2 33
  1448.  
  1449.         -attachForm     $browseButton  "top"    0
  1450.         -attachPosition $browseButton  "left"   2 33
  1451.         -attachForm     $browseButton  "bottom" 0
  1452.         -attachPosition $browseButton  "right"  2 67
  1453.  
  1454.         -attachForm     $cancelButton  "top"    0
  1455.         -attachPosition $cancelButton  "left"   2 67
  1456.         -attachForm     $cancelButton  "bottom" 0
  1457.         -attachForm     $cancelButton  "right"  0
  1458.         $buttonForm;
  1459.  
  1460.     formLayout -edit
  1461.         -attachForm     $bodyForm      "top"    4
  1462.         -attachForm     $bodyForm      "left"   4
  1463.         -attachControl  $bodyForm      "bottom" 4 $buttonForm
  1464.         -attachForm     $bodyForm      "right"  4
  1465.  
  1466.         -attachNone     $buttonForm    "top"
  1467.         -attachForm     $buttonForm    "left"   4
  1468.         -attachForm     $buttonForm    "bottom" 4
  1469.         -attachForm     $buttonForm    "right"  4
  1470.         $topForm;
  1471.  
  1472.     showWindow $window;
  1473. }
  1474.  
  1475. global proc toolboxCloseQuickLayoutImageEditor()
  1476. //
  1477. //    Description:
  1478. //        Close and delete the Quick Layout Image Editor.
  1479. //
  1480. //        Call this method to close the window. Safe to call from a control
  1481. //        within the window because it delays the deletion.
  1482. //
  1483. {
  1484.     if (`window -exists QuickLayoutImageEditor`) {
  1485.         evalDeferred("deleteUI -window QuickLayoutImageEditor");
  1486.     }
  1487. }
  1488.  
  1489. global proc toolboxBrowserCallback(string $bitmap, int $status)
  1490. //
  1491. //    Description:
  1492. //        This procedure is called when the bitmap browser is dismissed.
  1493. //
  1494. //        If a bitmap is selected then update the window to reflect the
  1495. //        selection.
  1496. //
  1497. //    Arguments:
  1498. //        $bitmap - The full path name of the bitmap selected. Or an empty
  1499. //                  string if no file was selected.
  1500. //
  1501. //        $status - Currently unused.
  1502. //
  1503. {
  1504.     
  1505.  
  1506.     if(`about -mac`){
  1507.         iconTextStaticLabel -edit -image1 $bitmap QuickLayoutImageEditorIcon;
  1508.     }else{
  1509.         string $tokenArray[], $image;
  1510.         int    $tokenCount;
  1511.         
  1512.         if ("" != $bitmap) {
  1513.             //
  1514.             //    Strip off the path.
  1515.             //
  1516.             $tokenCount = `tokenize $bitmap "/" $tokenArray`;
  1517.             if (0 < $tokenCount) {
  1518.                 $image = $tokenArray[$tokenCount - 1];
  1519.  
  1520.                 //    Update the field with the image name.
  1521.                 //
  1522.                 setParent QuickLayoutImageEditor;
  1523.                 iconTextStaticLabel -edit -image1 $image QuickLayoutImageEditorIcon;
  1524.             }
  1525.         }
  1526.     }
  1527. }
  1528.  
  1529. global proc toolboxSaveQuickLayoutImage(int $buttonIndex)
  1530. //
  1531. //    Description:
  1532. //        This procedure is called when the Quick Layout Image Editor's Save
  1533. //        button is pressed.
  1534. //
  1535. //        Save the image value.
  1536. //
  1537. {
  1538.     string $layoutArray[], $saveLayoutArray[];
  1539.     string $newImage, $image, $item;
  1540.     int    $found = false, $index, $layoutCount;
  1541.  
  1542.     //    Get the image name from the field.
  1543.     //
  1544.     $newImage = `iconTextStaticLabel -query -image1 QuickLayoutImageEditorIcon`;
  1545.  
  1546.     //    Determine the current values of the quick access buttons.
  1547.     //
  1548.     $layoutArray = `optionVar -query quickPanelButtonLayout`;
  1549.  
  1550.     //    Set the new value for the appropriate button.
  1551.     //
  1552.     setQuickButtonImage($layoutArray[$buttonIndex], $newImage);
  1553.  
  1554.     //    Update the Toolbox to reflect the image change.
  1555.     //
  1556.     updateToolbox();
  1557. }
  1558.  
  1559. global proc updateToolbox()
  1560. //
  1561. //    Description:
  1562. //        This procedure will update the Toolbox to reflect the main
  1563. //        window panel state and the quick layout button values.
  1564. //
  1565. //        Call this procedure whenever the panel configurations change or
  1566. //        the values of the quick access buttons change.
  1567. //        
  1568. {
  1569.     global string $gMainPane;
  1570.  
  1571.     global int    $kQuickLayoutInfoArrayElementSize;
  1572.     global int    $kImageIndex;
  1573.     global int    $kCommandIndex;
  1574.     global int    $kAnnotationIndex;
  1575.  
  1576.     string $configuration, $image, $annotation;
  1577.     string $panelArray[], $childArray[];
  1578.  
  1579.     //    Get the panel configuration.
  1580.     //
  1581.     $configuration = `paneLayout -query -configuration $gMainPane`;
  1582.  
  1583.     //    Update the panel configuration buttons.
  1584.     //
  1585.     updatePaneConfiguration($configuration);
  1586.  
  1587.     //    Get the panel contents.
  1588.     //
  1589.     $panelArray = getVisiblePanels();
  1590.  
  1591.     //    Apply the panel names to the annotations of the panel content 
  1592.     //    buttons.
  1593.     //
  1594.     for ($index = 0; $index < size($panelArray); $index++) {
  1595.  
  1596.         //    For some reason the label attached to model panels is not
  1597.         //    always in sync with "view" of that panel. Switching perspective
  1598.         //    or orthographic view in a model panel simply changes the camera
  1599.         //    in that panel. Very common to get a model panel say it is the
  1600.         //    Perspective View when in fact it is using an orthograpic camera.
  1601.         //
  1602.         //    The simply solution is to just call them all "Model View" 
  1603.         //    regardless of the camera.
  1604.         //
  1605.         if (`modelPanel -exists $panelArray[$index]`) {
  1606.             $annotation = "Model View";
  1607.         } else if (`panel -exists $panelArray[$index]`) {
  1608.             $annotation = `panel -query -label $panelArray[$index]`;
  1609.         } else {
  1610.             warning -showLineNumber true ("Panel \"" + $panelArray[$index] 
  1611.                 + "\" does not exist.");
  1612.             continue;
  1613.         }
  1614.  
  1615.         if (0 == $index) {
  1616.             $childArray = `layout -query -childArray ToolboxContentFrame0`;
  1617.         } else if (1 == $index) {
  1618.             $childArray = `layout -query -childArray ToolboxContentFrame1`;
  1619.         } else if (2 == $index) {
  1620.             $childArray = `layout -query -childArray ToolboxContentFrame2`;
  1621.         } else if (3 == $index) {
  1622.             $childArray = `layout -query -childArray ToolboxContentFrame3`;
  1623.         }
  1624.  
  1625.         control -edit -annotation $annotation $childArray[0];
  1626.     }
  1627.  
  1628.     //    Update the quick layout buttons.
  1629.     //
  1630.     string $layoutArray[], $image;
  1631.     $layoutArray = `optionVar -query quickPanelButtonLayout`;
  1632.  
  1633.     $childArray = `layout -query -childArray ToolboxConfigurationGrid`;
  1634.  
  1635.     $layoutIndex = 0;
  1636.     for ($index = 0; $index < size($childArray) - 1; $index += 1) {
  1637.         $image = getQuickButtonImage($layoutArray[$layoutIndex]);
  1638.         if ("" == $image) {
  1639.             $image = "vacantCell.xpm";
  1640.         }
  1641.         iconTextButton -edit
  1642.             -annotation $layoutArray[$layoutIndex]
  1643.             -command    ("setNamedPanelLayout \""
  1644.                         + $layoutArray[$layoutIndex] 
  1645.                         + "\"; updateToolbox()")
  1646.             -image1     $image
  1647.             $childArray[$index];
  1648.         $layoutIndex ++;
  1649.     }
  1650. }
  1651.  
  1652. global proc string [] getVisiblePanels()
  1653. //
  1654. //    Description:
  1655. //        Return a string array containing the names of the panels that are
  1656. //        currently visible in the main window's panel layout.
  1657. //
  1658. //    Returns:
  1659. //        A string array containing the visible panels. May return an empty
  1660. //        array if you call this method before panels have been added to
  1661. //        the main window pane layout.
  1662. //
  1663. {
  1664.     global string $gMainPane;
  1665.  
  1666.     string $visiblePanelArray[], $panel;
  1667.     int    $visiblePanelCount, $index;
  1668.  
  1669.     $visiblePanelCount = `paneLayout -query -numberOfVisiblePanes $gMainPane`;
  1670.  
  1671.     for ($index = 0; $index < $visiblePanelCount; $index++) {
  1672.         if (0 == $index) {
  1673.             $panel = `paneLayout -query -pane1 $gMainPane`;
  1674.             if ("" == $panel) {
  1675.                 //
  1676.                 //    If you call this procedure before panels have been added
  1677.                 //    to the pane layout then the first pane will have an 
  1678.                 //    empty panel.
  1679.                 //
  1680.                 //    In this case stop querying the panels and be sure to return
  1681.                 //    an empty string array result.
  1682.                 //
  1683.                 break;
  1684.             }
  1685.         } else if (1 == $index) {
  1686.             $panel = `paneLayout -query -pane2 $gMainPane`;
  1687.         } else if (2 == $index) {
  1688.             $panel = `paneLayout -query -pane3 $gMainPane`;
  1689.         } else if (3 == $index) {
  1690.             $panel = `paneLayout -query -pane4 $gMainPane`;
  1691.         } else {
  1692.             error -showLineError true ("Should never have more than 4 visible panels.");
  1693.         }
  1694.         
  1695.         $visiblePanelArray[$index] = $panel;
  1696.     }
  1697.  
  1698.     return $visiblePanelArray;
  1699. }
  1700.  
  1701. global proc int toolboxVisibilityStateChange(
  1702.     int    $newState,
  1703.     string $layout)
  1704. //
  1705. //    Description:
  1706. //        This procedure is called whenever the visibility state is changed.
  1707. //
  1708. //    Arguments:
  1709. //        newState - The new visibile state.
  1710. //
  1711. //        layout - The parent layout.
  1712. //
  1713. //    Returns:
  1714. //        true - If the change of state is to be allowed.
  1715. //
  1716. //        false - If the state change is rejected.
  1717. //
  1718. {
  1719.     int $result = true;
  1720.  
  1721.     //    Defer these commands because this proc is called when the visibility
  1722.     //    state is about to change. This proc must return true to accept 
  1723.     //    the state change. After this proc returns then restore the
  1724.     //    panel focus and update the pref menu.
  1725.     //
  1726.     evalDeferred("restoreLastPanelWithFocus(); updatePrefsMenu();");
  1727.  
  1728.     return $result;
  1729. }
  1730.  
  1731. //    Note that the following script block is not a procedure and will be
  1732. //    executed when this script file is sourced.
  1733. //
  1734. {
  1735.     global string $gToolboxForm;
  1736.  
  1737.     //    Create the Toolbox.
  1738.     //
  1739.     createToolbox($gToolboxForm);
  1740.  
  1741.     //    Update the Toolbox.
  1742.     //
  1743.     updateToolbox();
  1744.  
  1745.     setUIComponentStateCallback(
  1746.         "Tool Box", "toolboxVisibilityStateChange");
  1747.  
  1748.     //    Set the Toolbox's initial visibility.
  1749.     //
  1750.     setToolboxVisible(`optionVar -query toolboxVisible`);
  1751. }
  1752.